#pragma once

class System_Plugin;
class System_PluginManager : public Console_Subscriber
{
	struct PluginContainer
	{
		std::string			Directory;
		HMODULE				DLLModule;
		System_Plugin	*	Plug;
		PluginContainer() : DLLModule(NULL), Plug(NULL), Directory("") {}
		~PluginContainer() { Plug = NULL; DLLModule = NULL; Directory.clear();}
	};
	typedef std::map <std::string, PluginContainer> Plugs;

	Plugs	mPlugins;
public:
	System_PluginManager();
	virtual ~System_PluginManager();

	// Parse what is typed in console, check if plugin is loaded
	virtual void Parse(const std :: string & Input);	

	// Returns NULL if unable to load Do not delete this pointer
	System_Plugin * LoadPlugin(std::string ExtensionName);	
	
	// Returns NULL if unable to unload, either it is already unloaded or there is an error
	bool			UnloadPlugin(std::string ExtensionName);
	bool			UnloadAllPlugin();
};

extern SmartPtr <System_PluginManager> m_pSystem_PluginManager;